package com.lh;

import com.alibaba.dubbo.config.RegistryConfig;
import com.alibaba.dubbo.config.spring.context.annotation.DubboComponentScan;
import com.alibaba.dubbo.config.spring.context.annotation.EnableDubbo;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

//@Configuration
//@EnableDubbo(scanBasePackages = "com.lh.service.impl")//扫描添加了@Service的注解
//@PropertySource("classpath:dubbo-provider.properties")//配置文件的扫描

public class Provider2 {
    public static void main(String[] args) throws Exception {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ProviderConfiguration.class);
        context.start();
        System.out.println("提供者启动完成");
        System.in.read(); // 按任意键退出
    }

    @Configuration
    @EnableDubbo(scanBasePackages = "com.lh.service.impl")
//    @DubboComponentScan(basePackages = "com.lh.service.impl")
    @PropertySource("classpath:/dubbo-provider.properties")
    static class ProviderConfiguration {
        /**
         * 可以在配置文件中填写 dubbo.registry.address=zookeeper://39.100.230.98:2181
         * 这样的话 这个bean就可以不写了
         */
        @Bean
        public RegistryConfig registryConfig() {
            RegistryConfig registryConfig = new RegistryConfig();
            registryConfig.setAddress("zookeeper://127.0.0.1:2181");
            return registryConfig;
        }
    }
}
